from django.http import HttpResponseRedirect

def ajax(fn):
    def wrapped(request):
         if request.is_ajax():      
             return fn(request)
         return HttpResponseRedirect("/")
    return wrapped